import { createSlice, PayloadAction } from '@reduxjs/toolkit'

interface UserType {
	userInfo: UserInfoState
}

interface UserInfoState {
	aboutList: AboutListState[],
	id: string,
	nickname: string,
	tel: string,
	token: string
}

interface AboutListState {
	"image": string,
	"title": string,
	"id": string
}

const initialState: UserType = {
	userInfo: {
		aboutList: [],
		id: '',
		nickname: '',
		tel: '',
		token: ''
	}
}


const userSlice = createSlice({
	name: 'user',
	initialState,
	reducers: {
		loginSuccess(state, action: PayloadAction<UserInfoState>) {
			state.userInfo = action.payload
		}
	}
})
export const { loginSuccess } = userSlice.actions
export default userSlice.reducer